<?php


class AysMysql{
	
	
	public $dbsource = '';
	public function __construct(){
		
		$this->dbsource = new swoole_mysql();
		
		$this->dbConfig = [
            'host' => '115.28.184.144',
            'port' => 3306,
            'user' => 'jz@qiaozhuangjia',
            'password' => 'GBbfPSvAqU5JJND2',
            'database' => 'jz_qiaozhuangjia',
            'charset' => 'utf8',
        ];
	}
	
	
	public function update(){
		
	}
	
	public function add(){
		
	}
	
	// 执行逻辑
	public function execute(){
		$this->dbsource->connect($this->dbConfig,function($db, $result){
			echo "mysql-connect".PHP_EOL;
            if($result === false) {
                var_dump($db->connect_error);
                // todo
            }
			
			$sql = "select * from uz_plan  where  pid = 52341";
			
			$db->query($sql,function($db, $result){
				
				if($result === false){
					var_dump($db->error);
				}else if($result === true){
					var_dump($db->affected_rows);
				}else{
					print_r($result);
				}
				
				$db->close();
			});
			
		});
		return true;
	}
	
}


$obj = new AysMysql();

$obj->execute();